package com.esri.android.map.ags;

import android.util.Log;
import com.esri.android.map.DynamicLayer;
import com.esri.android.map.event.OnStatusChangedListener;
import com.esri.core.ags.LayerServiceInfo;
import com.esri.core.ags.MapServiceCapabilities;
import com.esri.core.ags.MapServiceInfo;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.a;
import com.esri.core.internal.tasks.ags.j;
import com.esri.core.internal.tasks.ags.m;
import com.esri.core.internal.tasks.ags.t;
import com.esri.core.internal.tasks.e;
import com.esri.core.io.EsriSecurityException;
import com.esri.core.io.UserCredentials;
import com.esri.core.map.CallbackListener;
import com.esri.core.map.DrawingInfo;
import com.esri.core.map.DynamicLayerInfo;
import com.esri.core.map.Field;
import com.esri.core.map.TimeAwareLayer;
import com.esri.core.map.TimeExtent;
import com.esri.core.map.TimeInfo;
import com.esri.core.map.TimeOptions;
import com.esri.core.map.popup.PopupFieldInfo;
import com.esri.core.map.popup.PopupInfo;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;

/* loaded from: classes.dex */
public class ArcGISDynamicMapServiceLayer extends DynamicLayer implements TimeAwareLayer {
    private TimeExtent A;
    private TimeInfo B;
    private boolean C;
    private List<DynamicLayerInfo> D;
    private final Map<Integer, DrawingInfo> E;
    private Map<Integer, LayerServiceInfo> F;
    int[] s;
    int[] t;
    Map<Integer, String> u;
    private MapServiceCapabilities v;
    private ArcGISLayerInfo[] w;
    private ArcGISLayerInfo[] x;
    private boolean y;
    private Map<Integer, TimeOptions> z;

    public ArcGISDynamicMapServiceLayer(String str, int[] iArr) {
        this(str, iArr, (UserCredentials) null, true);
    }

    public ArcGISDynamicMapServiceLayer(String str, int[] iArr, UserCredentials userCredentials, boolean z) {
        this(str, iArr, null, userCredentials, z);
    }

    public ArcGISDynamicMapServiceLayer(String str, int[] iArr, int[] iArr2, UserCredentials userCredentials, boolean z) {
        super(str);
        this.v = null;
        this.w = null;
        this.x = null;
        this.u = null;
        this.z = new HashMap();
        this.C = false;
        this.D = new ArrayList();
        this.E = new HashMap();
        this.F = new HashMap();
        if (iArr != null) {
            Arrays.sort(iArr);
        }
        this.s = iArr;
        this.credentials = userCredentials;
        if (iArr2 != null) {
            Arrays.sort(iArr2);
            this.t = iArr2;
        }
        if (z) {
            try {
                getPoolExecutor().submit(new Runnable() { // from class: com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.1
                    @Override // java.lang.Runnable
                    public void run() {
                        ArcGISDynamicMapServiceLayer.this.initLayer();
                    }
                });
            } catch (RejectedExecutionException unused) {
            }
        }
    }

    public ArcGISDynamicMapServiceLayer(String str) {
        this(str, (int[]) null, (UserCredentials) null, true);
    }

    public ArcGISDynamicMapServiceLayer(String str, int[] iArr, UserCredentials userCredentials) {
        this(str, iArr, (Map<Integer, DrawingInfo>) null, userCredentials);
    }

    public ArcGISDynamicMapServiceLayer(String str, int[] iArr, Map<Integer, DrawingInfo> map, UserCredentials userCredentials) {
        super(str);
        this.v = null;
        this.w = null;
        this.x = null;
        this.u = null;
        this.z = new HashMap();
        this.C = false;
        this.D = new ArrayList();
        HashMap hashMap = new HashMap();
        this.E = hashMap;
        this.F = new HashMap();
        if (iArr != null) {
            Arrays.sort(iArr);
        }
        this.s = iArr;
        if (map != null) {
            hashMap.putAll(map);
        }
        setCredentials(userCredentials);
        try {
            getServiceExecutor().submit(new Runnable() { // from class: com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.2
                @Override // java.lang.Runnable
                public void run() {
                    ArcGISDynamicMapServiceLayer.this.initLayer();
                }
            });
        } catch (RejectedExecutionException unused) {
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // com.esri.android.map.DynamicLayer, com.esri.android.map.Layer
    public void initLayer() {
        if (this.nativeHandle == 0) {
            this.nativeHandle = create();
        }
        if (this.nativeHandle == 0) {
            changeStatus(OnStatusChangedListener.STATUS.fromInt(-1000));
            Log.e(a.a, "initialize fail : " + OnStatusChangedListener.STATUS.fromInt(-1000));
            return;
        }
        try {
            MapServiceInfo execute = this.serviceInfo != null ? (MapServiceInfo) this.serviceInfo : new t(getUrl(), this.credentials).execute();
            if (this.serviceInfo == null) {
                this.serviceInfo = execute;
            }
            if (execute == null) {
                throw new Exception("layer initialization failed due to invalid URL or credential");
            }
            if (getName() == null || getName().length() < 1) {
                setName(execute.getMapName());
            }
            this.v = execute.getCapabilities();
            setFullExtent(execute.getFullExtent());
            setDefaultSpatialReference(execute.getSpatialReference());
            a(execute.getMapServiceLayerInfos());
            boolean isDynamicLayersSupported = execute.isDynamicLayersSupported();
            this.C = isDynamicLayersSupported;
            if (isDynamicLayersSupported && this.D.isEmpty()) {
                this.D.addAll(createDynamicLayerInfos());
            }
            initializeMinMaxScale(execute.getMinScale(), execute.getMaxScale());
            if (getInitialExtent() == null) {
                setInitialExtent(execute.getInitialExtent());
            } else {
                setInitialExtent((Envelope) GeometryEngine.project(getInitialExtent(), SpatialReference.create(4326), getDefaultSpatialReference()));
            }
            this.B = execute.getTimeInfo();
            super.initLayer();
        } catch (Exception e) {
            Log.e(a.a, "url =" + getUrl(), e);
            if (e instanceof EsriSecurityException) {
                changeStatus(OnStatusChangedListener.STATUS.fromInt(((EsriSecurityException) e).getCode()));
            } else {
                changeStatus(OnStatusChangedListener.STATUS.fromInt(OnStatusChangedListener.EsriStatusException.INIT_FAILED_ARCGIS_DYNAMIC_LAYER));
            }
        }
    }

    public MapServiceInfo getMapServiceInfo() {
        if (this.serviceInfo instanceof MapServiceInfo) {
            return (MapServiceInfo) this.serviceInfo;
        }
        return null;
    }

    void a(LayerServiceInfo[] layerServiceInfoArr) {
        if (layerServiceInfoArr != null) {
            ArrayList arrayList = new ArrayList();
            this.x = a(layerServiceInfoArr, arrayList, this.s, this.t);
            this.w = (ArcGISLayerInfo[]) arrayList.toArray(new ArcGISLayerInfo[0]);
            return;
        }
        this.w = new ArcGISLayerInfo[0];
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static ArcGISLayerInfo[] a(LayerServiceInfo[] layerServiceInfoArr, ArrayList<ArcGISLayerInfo> arrayList, int[] iArr, int[] iArr2) {
        ArcGISLayerInfo arcGISLayerInfo;
        ArrayList arrayList2 = new ArrayList();
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        LinkedHashMap linkedHashMap2 = new LinkedHashMap();
        for (LayerServiceInfo layerServiceInfo : layerServiceInfoArr) {
            ArcGISLayerInfo a = a(layerServiceInfo, (ArcGISLayerInfo) null, iArr, iArr2);
            linkedHashMap.put(Integer.valueOf(layerServiceInfo.getId()), a);
            arrayList2.add(a);
            if (layerServiceInfo.getParentLayerId() >= 0) {
                linkedHashMap2.put(a, Integer.valueOf(layerServiceInfo.getParentLayerId()));
            } else {
                arrayList.add(a);
            }
        }
        for (Map.Entry entry : linkedHashMap2.entrySet()) {
            if (entry.getKey() != null && (arcGISLayerInfo = (ArcGISLayerInfo) linkedHashMap.get(entry.getValue())) != null) {
                ArcGISLayerInfo arcGISLayerInfo2 = (ArcGISLayerInfo) entry.getKey();
                arcGISLayerInfo.g.add(arcGISLayerInfo2);
                arcGISLayerInfo2.c = arcGISLayerInfo;
            }
        }
        return (ArcGISLayerInfo[]) arrayList2.toArray(new ArcGISLayerInfo[0]);
    }

    @Override // com.esri.core.map.TimeAwareLayer
    public boolean isTimeAware() {
        return isInitialized() && this.B != null;
    }

    public Map<Integer, TimeOptions> getTimeOptions() {
        return this.z;
    }

    public void setTimeOptions(Map<Integer, TimeOptions> map) {
        if (map == null || map.isEmpty()) {
            this.z.clear();
        } else {
            this.z.putAll(map);
        }
    }

    @Override // com.esri.core.map.TimeAwareLayer
    public TimeExtent getTimeExtent() {
        if (isTimeAware()) {
            return this.B.getTimeExtent();
        }
        return null;
    }

    @Override // com.esri.core.map.TimeAwareLayer
    public TimeExtent getTimeInterval() {
        return this.A;
    }

    @Override // com.esri.core.map.TimeAwareLayer
    public void setTimeInterval(TimeExtent timeExtent) {
        this.A = timeExtent;
        refresh();
    }

    @Override // com.esri.core.map.TimeAwareLayer
    public TimeInfo getTimeInfo() {
        return this.B;
    }

    public MapServiceCapabilities getCapabilities() {
        return this.v;
    }

    public ArcGISLayerInfo[] getLayers() {
        return this.w;
    }

    public ArcGISLayerInfo[] getAllLayers() {
        return this.x;
    }

    @Override // com.esri.android.map.DynamicLayer
    protected byte[] getImage(int i, int i2, Envelope envelope) throws Exception {
        return a(i, i2, envelope, getAllLayers());
    }

    byte[] a(int i, int i2, Envelope envelope, ArcGISLayerInfo[] arcGISLayerInfoArr) throws Exception {
        m mVar = new m(envelope, getSpatialReference(), i, i2);
        mVar.b(getLayerDefinitions());
        mVar.c(isWrapAroundEnabled());
        mVar.a(getCenterMeridan());
        mVar.d(isCrossDateline());
        if (isDynamicLayersSupported() && this.D != null) {
            mVar.a(c());
        }
        j jVar = new j(mVar, getUrl(), getCredentials());
        if (arcGISLayerInfoArr != null && arcGISLayerInfoArr.length > 0) {
            StringBuilder sb = new StringBuilder();
            boolean z = false;
            for (ArcGISLayerInfo arcGISLayerInfo : arcGISLayerInfoArr) {
                if ((arcGISLayerInfo.getLayers() == null || arcGISLayerInfo.getLayers().length < 1) && !a(arcGISLayerInfo)) {
                    if (z) {
                        sb.append(",");
                    } else {
                        z = true;
                    }
                    sb.append(arcGISLayerInfo.b);
                }
            }
            mVar.b(sb.toString());
        }
        mVar.a(getDpi());
        mVar.a(getSpatialReference());
        if (isTimeAware()) {
            mVar.a(this.z);
            TimeExtent timeExtent = this.A;
            if (timeExtent != null) {
                mVar.a(timeExtent);
            }
        }
        return jVar.execute();
    }

    private boolean a(ArcGISLayerInfo arcGISLayerInfo) {
        if (arcGISLayerInfo.getParentLayer() != null) {
            return a(arcGISLayerInfo.getParentLayer()) & arcGISLayerInfo.d;
        }
        return arcGISLayerInfo.d;
    }

    static ArcGISLayerInfo a(LayerServiceInfo layerServiceInfo, ArcGISLayerInfo arcGISLayerInfo, int[] iArr, int[] iArr2) {
        ArcGISLayerInfo arcGISLayerInfo2 = new ArcGISLayerInfo(layerServiceInfo.getName(), layerServiceInfo.getId());
        arcGISLayerInfo2.a(layerServiceInfo.getMinScale());
        arcGISLayerInfo2.b(layerServiceInfo.getMaxScale());
        boolean z = false;
        arcGISLayerInfo2.d = (iArr == null || iArr.length <= 0) ? layerServiceInfo.isDefaultVisibility() : Arrays.binarySearch(iArr, arcGISLayerInfo2.b) >= 0;
        arcGISLayerInfo2.h = (iArr2 == null || iArr2.length <= 0 || Arrays.binarySearch(iArr2, arcGISLayerInfo2.b) < 0) ? true : true;
        if (arcGISLayerInfo != null) {
            arcGISLayerInfo.a(arcGISLayerInfo2);
        }
        arcGISLayerInfo2.k = layerServiceInfo;
        return arcGISLayerInfo2;
    }

    public Map<Integer, String> getLayerDefinitions() {
        return this.u;
    }

    @Override // com.esri.android.map.Layer
    public final String getQueryUrl(int i) {
        String queryUrl = super.getQueryUrl(i);
        if (queryUrl != null) {
            return queryUrl;
        }
        MapServiceInfo mapServiceInfo = getMapServiceInfo();
        if (mapServiceInfo == null) {
            return null;
        }
        LayerServiceInfo[] mapServiceLayerInfos = mapServiceInfo.getMapServiceLayerInfos();
        if (mapServiceLayerInfos != null) {
            for (LayerServiceInfo layerServiceInfo : mapServiceLayerInfos) {
                if (layerServiceInfo.getId() == i && (layerServiceInfo.getSubLayerIds() == null || (layerServiceInfo.getSubLayerIds() != null && layerServiceInfo.getSubLayerIds().size() == 0))) {
                    return getUrl() + "/" + i;
                }
            }
            return queryUrl;
        }
        return queryUrl;
    }

    public void setLayerDefinitions(Map<Integer, String> map) {
        this.u = map;
    }

    @Override // com.esri.android.map.Layer
    @Deprecated
    public ArcGISPopupInfo getPopupInfo(int i) {
        ArcGISPopupInfo popupInfo = super.getPopupInfo(i);
        if (popupInfo != null && popupInfo.a == null) {
            try {
                popupInfo.fetchLayerInfo(popupInfo.c, this.credentials);
            } catch (Exception e) {
                Log.e(a.a, "url =" + getUrl(), e);
            }
        }
        return popupInfo;
    }

    @Deprecated
    public ArcGISPopupInfo createPopupInfo(int i) {
        Field[] fields;
        ArcGISPopupInfo popupInfo = getPopupInfo(i);
        if (popupInfo == null) {
            popupInfo = new ArcGISPopupInfo(new PopupInfo());
            try {
                popupInfo.fetchLayerInfo(getUrl() + "/" + i, this.credentials);
                LinkedHashMap linkedHashMap = new LinkedHashMap();
                for (Field field : popupInfo.a.getFields()) {
                    PopupFieldInfo popupFieldInfo = new PopupFieldInfo();
                    popupFieldInfo.setFieldName(field.getName());
                    popupFieldInfo.setLabel(field.getAlias());
                    linkedHashMap.put(field.getName(), popupFieldInfo);
                }
                popupInfo.setFieldInfos(linkedHashMap);
            } catch (Exception e) {
                Log.e(a.a, "url =" + getUrl(), e);
            }
        }
        return popupInfo;
    }

    public Future<ArcGISPopupInfo> createPopupInfo(final int i, final CallbackListener<ArcGISPopupInfo> callbackListener) {
        return e.b.submit(new Callable<ArcGISPopupInfo>() { // from class: com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.3
            /* JADX WARN: Removed duplicated region for block: B:43:0x0128  */
            @Override // java.util.concurrent.Callable
            /* renamed from: a */
            /*
                Code decompiled incorrectly, please refer to instructions dump.
                To view partially-correct code enable 'Show inconsistent code' option in preferences
            */
            public com.esri.android.map.ags.ArcGISPopupInfo call() throws java.lang.Exception {
                /*
                    Method dump skipped, instructions count: 302
                    To view this dump change 'Code comments level' option to 'DEBUG'
                */
                throw new UnsupportedOperationException("Method not decompiled: com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.AnonymousClass3.call():com.esri.android.map.ags.ArcGISPopupInfo");
            }
        });
    }

    public Future<ArcGISPopupInfo> fetchPopupInfo(final int i, final CallbackListener<ArcGISPopupInfo> callbackListener) {
        return e.b.submit(new Callable<ArcGISPopupInfo>() { // from class: com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.4
            /* JADX WARN: Removed duplicated region for block: B:29:0x0090  */
            @Override // java.util.concurrent.Callable
            /* renamed from: a */
            /*
                Code decompiled incorrectly, please refer to instructions dump.
                To view partially-correct code enable 'Show inconsistent code' option in preferences
            */
            public com.esri.android.map.ags.ArcGISPopupInfo call() throws java.lang.Exception {
                /*
                    r5 = this;
                    com.esri.android.map.ags.ArcGISDynamicMapServiceLayer r0 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.this
                    int r1 = r2
                    com.esri.android.map.ags.ArcGISPopupInfo r0 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.b(r0, r1)
                    java.lang.Thread r1 = java.lang.Thread.currentThread()     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    boolean r1 = r1.isInterrupted()     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    if (r1 != 0) goto L76
                    if (r0 == 0) goto L6e
                    com.esri.core.ags.LayerServiceInfo r1 = r0.a     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    if (r1 != 0) goto L6e
                    com.esri.android.map.ags.ArcGISDynamicMapServiceLayer r1 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.this     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    java.util.Map r1 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.a(r1)     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    int r2 = r2     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    java.lang.Integer r2 = java.lang.Integer.valueOf(r2)     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    java.lang.Object r1 = r1.get(r2)     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    com.esri.core.ags.LayerServiceInfo r1 = (com.esri.core.ags.LayerServiceInfo) r1     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    r0.a = r1     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    com.esri.core.ags.LayerServiceInfo r1 = r0.a     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    if (r1 != 0) goto L6e
                    com.esri.core.internal.tasks.ags.v r1 = new com.esri.core.internal.tasks.ags.v     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    java.lang.StringBuilder r2 = new java.lang.StringBuilder     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    r2.<init>()     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    com.esri.android.map.ags.ArcGISDynamicMapServiceLayer r3 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.this     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    java.lang.String r3 = r3.getUrl()     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    r2.append(r3)     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    java.lang.String r3 = "/"
                    r2.append(r3)     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    int r3 = r2     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    r2.append(r3)     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    java.lang.String r2 = r2.toString()     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    com.esri.android.map.ags.ArcGISDynamicMapServiceLayer r3 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.this     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    com.esri.core.io.UserCredentials r3 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.d(r3)     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    r1.<init>(r2, r3)     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    com.esri.core.ags.LayerServiceInfo r1 = r1.execute()     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    r0.a = r1     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    com.esri.android.map.ags.ArcGISDynamicMapServiceLayer r1 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.this     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    java.util.Map r1 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.a(r1)     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    int r2 = r2     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    java.lang.Integer r2 = java.lang.Integer.valueOf(r2)     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    com.esri.core.ags.LayerServiceInfo r3 = r0.a     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    r1.put(r2, r3)     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                L6e:
                    com.esri.core.map.CallbackListener r1 = r3
                    if (r1 == 0) goto L75
                    r1.onCallback(r0)
                L75:
                    return r0
                L76:
                    java.lang.InterruptedException r1 = new java.lang.InterruptedException     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    r1.<init>()     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                    throw r1     // Catch: java.lang.Throwable -> L7c java.lang.Exception -> L7e
                L7c:
                    r1 = move-exception
                    goto L8c
                L7e:
                    r0 = move-exception
                    r1 = 0
                    com.esri.core.map.CallbackListener r2 = r3     // Catch: java.lang.Throwable -> L88
                    if (r2 == 0) goto L87
                    r2.onError(r0)     // Catch: java.lang.Throwable -> L88
                L87:
                    throw r0     // Catch: java.lang.Throwable -> L88
                L88:
                    r0 = move-exception
                    r4 = r1
                    r1 = r0
                    r0 = r4
                L8c:
                    com.esri.core.map.CallbackListener r2 = r3
                    if (r2 == 0) goto L93
                    r2.onCallback(r0)
                L93:
                    throw r1
                */
                throw new UnsupportedOperationException("Method not decompiled: com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.AnonymousClass4.call():com.esri.android.map.ags.ArcGISPopupInfo");
            }
        });
    }

    public LayerServiceInfo getLayerServiceInfo(int i) {
        Map<Integer, LayerServiceInfo> map = this.F;
        if (map == null) {
            return null;
        }
        return map.get(Integer.valueOf(i));
    }

    public Future<LayerServiceInfo> fetchLayerServiceInfo(final int i, final CallbackListener<LayerServiceInfo> callbackListener) {
        return e.b.submit(new Callable<LayerServiceInfo>() { // from class: com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.5
            /* JADX WARN: Removed duplicated region for block: B:25:0x007a  */
            @Override // java.util.concurrent.Callable
            /* renamed from: a */
            /*
                Code decompiled incorrectly, please refer to instructions dump.
                To view partially-correct code enable 'Show inconsistent code' option in preferences
            */
            public com.esri.core.ags.LayerServiceInfo call() throws java.lang.Exception {
                /*
                    r5 = this;
                    com.esri.android.map.ags.ArcGISDynamicMapServiceLayer r0 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.this
                    java.util.Map r0 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.a(r0)
                    int r1 = r2
                    java.lang.Integer r1 = java.lang.Integer.valueOf(r1)
                    java.lang.Object r0 = r0.get(r1)
                    com.esri.core.ags.LayerServiceInfo r0 = (com.esri.core.ags.LayerServiceInfo) r0
                    java.lang.Thread r1 = java.lang.Thread.currentThread()     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    boolean r1 = r1.isInterrupted()     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    if (r1 != 0) goto L60
                    if (r0 != 0) goto L58
                    com.esri.core.internal.tasks.ags.v r1 = new com.esri.core.internal.tasks.ags.v     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    java.lang.StringBuilder r2 = new java.lang.StringBuilder     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    r2.<init>()     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    com.esri.android.map.ags.ArcGISDynamicMapServiceLayer r3 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.this     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    java.lang.String r3 = r3.getUrl()     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    r2.append(r3)     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    java.lang.String r3 = "/"
                    r2.append(r3)     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    int r3 = r2     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    r2.append(r3)     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    java.lang.String r2 = r2.toString()     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    com.esri.android.map.ags.ArcGISDynamicMapServiceLayer r3 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.this     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    com.esri.core.io.UserCredentials r3 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.e(r3)     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    r1.<init>(r2, r3)     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    com.esri.core.ags.LayerServiceInfo r0 = r1.execute()     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    com.esri.android.map.ags.ArcGISDynamicMapServiceLayer r1 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.this     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    java.util.Map r1 = com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.a(r1)     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    int r2 = r2     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    java.lang.Integer r2 = java.lang.Integer.valueOf(r2)     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    r1.put(r2, r0)     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                L58:
                    com.esri.core.map.CallbackListener r1 = r3
                    if (r1 == 0) goto L5f
                    r1.onCallback(r0)
                L5f:
                    return r0
                L60:
                    java.lang.InterruptedException r1 = new java.lang.InterruptedException     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    r1.<init>()     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                    throw r1     // Catch: java.lang.Throwable -> L66 java.lang.Exception -> L68
                L66:
                    r1 = move-exception
                    goto L76
                L68:
                    r0 = move-exception
                    r1 = 0
                    com.esri.core.map.CallbackListener r2 = r3     // Catch: java.lang.Throwable -> L72
                    if (r2 == 0) goto L71
                    r2.onError(r0)     // Catch: java.lang.Throwable -> L72
                L71:
                    throw r0     // Catch: java.lang.Throwable -> L72
                L72:
                    r0 = move-exception
                    r4 = r1
                    r1 = r0
                    r0 = r4
                L76:
                    com.esri.core.map.CallbackListener r2 = r3
                    if (r2 == 0) goto L7d
                    r2.onCallback(r0)
                L7d:
                    throw r1
                */
                throw new UnsupportedOperationException("Method not decompiled: com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.AnonymousClass5.call():com.esri.core.ags.LayerServiceInfo");
            }
        });
    }

    public boolean retrieveLegendInfo() {
        if (!this.y && isShowLegend()) {
            this.y = a((MapServiceInfo) this.serviceInfo, this.x, getCredentials());
        }
        return this.y;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static boolean a(MapServiceInfo mapServiceInfo, ArcGISLayerInfo[] arcGISLayerInfoArr, UserCredentials userCredentials) {
        try {
            return new com.esri.core.internal.a.a.a(arcGISLayerInfoArr, mapServiceInfo.getUrl(), userCredentials).execute().booleanValue();
        } catch (Exception unused) {
            return false;
        }
    }

    public boolean isDynamicLayersSupported() {
        if (isInitialized()) {
            return this.C;
        }
        return false;
    }

    public void setDynamicLayerInfos(List<DynamicLayerInfo> list) {
        List<DynamicLayerInfo> list2;
        if ((list == null || list.isEmpty()) && (list2 = this.D) != null) {
            list2.clear();
        } else {
            this.D = list;
        }
    }

    public List<DynamicLayerInfo> createDynamicLayerInfos() {
        ArrayList arrayList = new ArrayList();
        if (this.C) {
            int[] iArr = this.s;
            int i = 0;
            if (iArr != null && iArr.length > 0) {
                int length = iArr.length;
                while (i < length) {
                    arrayList.add(new DynamicLayerInfo(iArr[i]));
                    i++;
                }
            } else {
                ArcGISLayerInfo[] arcGISLayerInfoArr = this.x;
                if (arcGISLayerInfoArr != null && arcGISLayerInfoArr.length > 0) {
                    int length2 = arcGISLayerInfoArr.length;
                    while (i < length2) {
                        ArcGISLayerInfo arcGISLayerInfo = arcGISLayerInfoArr[i];
                        if (arcGISLayerInfo.isVisible()) {
                            arrayList.add(new DynamicLayerInfo(arcGISLayerInfo.getId()));
                        }
                        i++;
                    }
                }
            }
        }
        return arrayList;
    }

    public List<DynamicLayerInfo> getDynamicLayerInfos() {
        return this.D;
    }

    public void setDrawingOptions(Map<Integer, DrawingInfo> map) {
        if (map == null || map.isEmpty()) {
            this.E.clear();
        } else {
            this.E.putAll(map);
        }
    }

    public Map<Integer, DrawingInfo> getDrawingOptions() {
        return this.E;
    }

    private List<DynamicLayerInfo> c() {
        TimeOptions timeOptions;
        String str;
        DrawingInfo drawingInfo;
        ArrayList arrayList = new ArrayList();
        for (DynamicLayerInfo dynamicLayerInfo : this.D) {
            int id = dynamicLayerInfo.getId();
            if (a(id)) {
                Map<Integer, DrawingInfo> map = this.E;
                if (map != null && (drawingInfo = map.get(Integer.valueOf(id))) != null) {
                    dynamicLayerInfo.setDrawingInfo(drawingInfo);
                }
                Map<Integer, String> map2 = this.u;
                if (map2 != null && (str = map2.get(Integer.valueOf(id))) != null && str.length() > 0) {
                    dynamicLayerInfo.setDefinitionExpression(str);
                }
                Map<Integer, TimeOptions> map3 = this.z;
                if (map3 != null && (timeOptions = map3.get(Integer.valueOf(id))) != null) {
                    dynamicLayerInfo.setLayerTimeOptions(timeOptions);
                }
                arrayList.add(dynamicLayerInfo);
            }
        }
        return arrayList;
    }

    private boolean a(int i) {
        ArcGISLayerInfo[] arcGISLayerInfoArr;
        for (ArcGISLayerInfo arcGISLayerInfo : this.x) {
            if (arcGISLayerInfo.getId() == i) {
                return arcGISLayerInfo.isVisible();
            }
        }
        return true;
    }
}
